package org.dairy.farms.model;

import org.dairy.farms.interceptor.hibernate.AuditListener;
import org.dairy.farms.interceptor.hibernate.Auditable;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
import java.sql.Date;

/**
 * Created by IntelliJ IDEA.
 * User: gduggira
 * Date: Jun 8, 2011
 * Time: 1:47:45 PM
 */
@javax.persistence.Table(name = "FARM")
@Entity
//@EntityListeners({AuditListener.class})
public class Farm implements Auditable {
    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue
    private Long Id;

    @javax.persistence.Column(name = "NAME")
    private String name;

    @javax.persistence.Column(name = "DESCRIPTION")
    private String description;

    @javax.persistence.Column(name = "START_DATE")
    private Date startDate;

    @OneToMany(mappedBy = "farm", targetEntity = Person.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Person> persons = new HashSet<Person>();
    
    @OneToMany(mappedBy = "farm", targetEntity = Livestock.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Livestock> livestocks = new HashSet<Livestock>();

    @OneToMany(mappedBy = "farm", targetEntity = FarmExpense.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<FarmExpense> farmExpenses = new HashSet<FarmExpense>();


    public Long getId() {
        return Id;
    }

    public void setId(Long id) {
        Id = id;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }


    public Set<Person> getPersons() {
        return persons;
    }


    public Set<Livestock> getAnimals() {
        return livestocks;
    }

    public void setAnimals(Set<Livestock> livestocks) {
        this.livestocks = livestocks;
    }

    public void setPersons(Set<Person> persons) {
        this.persons = persons;
    }

    public Set<Livestock> getLivestocks() {
        return livestocks;
    }

    public void setLivestocks(Set<Livestock> livestocks) {
        this.livestocks = livestocks;
    }

   /* public Set<Expense> getExpenses() {
        return expenses;
    }

    public void setExpenses(Set<Expense> expenses) {
        this.expenses = expenses;
    }*/

    @Embedded
    private AuditInfo auditInfo =new AuditInfo();

    public AuditInfo getAuditInfo() {
        return auditInfo;
    }

    public void setAuditInfo(AuditInfo auditInfo) {
        this.auditInfo = auditInfo;
    }
}
